package com.example.stumanager.admin;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.stumanager.R;
import com.example.stumanager.entity.UserEntity;

import java.util.ArrayList;

/**
 * 学生信息查看
 */
public class StudentInformationView extends ArrayAdapter<UserEntity> {
    public StudentInformationView(@NonNull Context context, int resource, @NonNull ArrayList objects) {
        super(context, resource, objects);
    }
    //每个子项被滚动到屏幕内的时候会被调用
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        UserEntity w=getItem(position);

        View view= LayoutInflater.from(getContext()).inflate(R.layout.student_information_view,parent,false);

        TextView number =view.findViewById(R.id.number);
        TextView name =view.findViewById(R.id.name);
        TextView dormitory =view.findViewById(R.id.dormitory);
        TextView grade=view.findViewById(R.id.grade);

        number.setText("学生学号："+w.getNumber());
        name.setText("学生姓名："+w.getName());
        dormitory.setText("学生宿舍："+w.getDormitory());
        grade.setText("学生年级："+w.getGrade());


        return view;
    }

}
